<tc_include file="Public:header" />
<link href="__PUBLIC__/js/artDialog/skins/default.css" rel="stylesheet" />
  <div id="content-container" class="container">
      <if condition="empty($avatar)">
       <div class="alert alert-warning alert-dismissable">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            <strong>您还没有头像</strong>。拥有一个独有的头像，老师和同学们能更容易关注到你哦～～ <a href="{:u('user/center/pic')}"" class="alert-link" target="_blank">点击设置</a>
	  </div>
	  <else/>
	    <if condition="empty($user['user_nicename'])">
	     <div class="alert alert-warning alert-dismissable">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            <strong>您还没设置昵称</strong>。请到个人设置里面设置～～ <a href="{:u('user/center/setting')}" class="alert-link" target="_blank">点击设置</a>
         </div>
        </if>
	 </if>
     <div class="row row-3-9">
        <div class="col-md-3">
           <div class="sidenav">
             <ul class="list-group">
             <if condition="$user_type neq 2">
               <li class="list-group-heading">我的教学</li>
               <li class="list-group-item "><a href="{:u('teacher/Center/index')}">课程管理</a></li>
			   <li class="list-group-item"><a href="{:u('teacher/Center/createcourse')}">课程发布</a></li>
               <li class="list-group-item"><a href="{:u('teacher/Center/sales')}">课程订单</a></li>
			   <li class="list-group-item"><a href="{:u('teacher/Center/ziyuanku')}">我的资源库</a></li>
             </if>
               <li class="list-group-heading" style="margin-top:10px;">我的学习</li>
               <li class="list-group-item" ><a href="{:u('user/center/index')}">我的课程</a></li>
               <li class="list-group-item"  ><a href="{:u('user/center/jihuo')}">激活课程</a></li>
               <li class="list-group-heading" style="margin-top:10px;">个人设置</li>
               <li class="list-group-item "><a href="{:u('user/center/setting')}"> 基础信息</a></li>
               <li class="list-group-item "><a href="{:u('user/center/pic')}">头像设置</a></li>
               <li class="list-group-item "><a href="{:u('user/center/security')}">修改密码</a></li>          
               <li class="list-group-heading" style="margin-top:10px;">账户中心</li>
               <li class="list-group-item "><a href="{:u('user/center/count')}">我的账户</a></li>
               <li class="list-group-item "><a href="{:u('user/center/order')}">我的订单</a></li>
               <li class="list-group-item "><a href="{:u('user/center/card')}">点卡充值</a></li>
            </ul>
          </div>
        </div>
        <div class="col-md-9">	
          <div class="panel panel-default panel-col">
	        <div class="panel-heading">发布普通课程</div>
	          <div class="panel-body">
				  <form name="myform" id="myform" action="{:U('Teacher/Center/add_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
					<input type="hidden" name="domain" id="domain" value={$domain} />
					<input type="hidden" name="code" id="code" value="" />
					<input type="hidden" name="count" id="count" value="" />
					<div class="form-group">
						<label class="col-md-2 control-label">课程标题</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_weixin" name="cs_name" class="form-control" value="{$title}">
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">所属分类</label>
						<div class="col-md-7 controls">
							<select name="ty_id" id='first' class="form-control" style="width:225px;float:left;margin-right:17px;">{$taxonomys}</select>
				            <span id="second"> <select id="label" class="form-control" style="width:225px;" name="labelid"> </select> </span> 
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">课程价格</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_weixin" name="cs_price" class="form-control" >
							<div class="help-block" style="display:none;"></div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">学习目标</label>
						<div class="col-md-7 controls">
							<textarea class="form-control" rows="4"  style='width:467px' name="mubiao"></textarea>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">适合人群</label>
						<div class="col-md-7 controls">
							<textarea class="form-control" rows="3"  style='width:467px' name="shihe"></textarea>
						</div>
					</div>

					<div class="form-group">
						<label class="col-md-2 control-label">章节数量</label>
						<div class="col-md-7 controls">
							<input type="text" id="profile_weixin" name="sec_numbers" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">课程图片</label>
						<div class="col-md-7 controls">
							<div  style="text-align: center;"><input type='hidden' name='cs_picture' id='thumb' value=''>
		     	              <a href='javascript:void(0);' onclick="flashupload('thumb_images', '附件上传','thumb',thumb_images,'1,jpg|jpeg|gif|png|bmp|mp4,1,,,1','','','');return false;">
			                  <img src='__PUBLIC__/images/course.png' id='thumb_preview'  style='cursor:hand' /></a>
                             </div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">课程描述</label>
						<div class="col-md-7 controls">
						  <td><script id="content" type="text/plain"  name="cs_brief" style="width:100%;height:300px;"></script></td>
						</div>
					</div>
					<input type="hidden" id="type" name="type" value="{$type}"/>
					<div class="row">
						<div class="col-md-7 col-md-offset-2">
							<button id="profile-save-btn"  type="submit" class="btn btn-primary js-ajax-submit">发布 </button>
						</div>
					</div>
			     </form>	   
		      </div>
	         </div>
          </div>
     </div>
   </div>
<tc_include file="Public:scripts" />
 <script language="javascript"> 
$(function(){ 
$("#second").hide(); 
$("#first").change(function(){  
var parentId=$("#first").val(); 
if(null!= parentId && ""!=parentId){
	
$.getJSON("{:U('Teacher/Center/Labelselect')}",{id:parentId},function(myJSON){
var options=""; 
if(myJSON.length>0){ 
options+="<option value='-1'>==请选择标签==</option>"; 
for(var i=0;i<myJSON.length;i++){ 
options+="<option value="+myJSON[i].id+">"+myJSON[i].labelname+"</option>"; 
} 
$("#label").html(options); 
$("#second").show(); 
} 
else if(myJSON.length<=0){ 
$("#second").hide(); 
} 
}); 
} 
else{ 
$("#second").hide(); 
} 
}); 
}); 
</script>

<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.js"></script>
<script type="text/javascript"> 
    $(function () {
	$(".js-ajax-close-btn").on('click', function (e) {
	    e.preventDefault();
	    Wind.use("artDialog", function () {
	        art.dialog({
	            id: "question",
	            icon: "question",
	            fixed: true,
	            lock: true,
	            background: "#CCCCCC",
	            opacity: 0,
	            content: "您确定需要关闭当前页面嘛？",
	            ok:function(){
					setCookie("refersh_time",1);
					window.close();
					return true;
				}
	        });
	    });
	});
	/////---------------------
	 Wind.use('validate', 'ajaxForm', 'artDialog', function () {
			//javascript
	        
	            //编辑器
	            editorcontent = new baidu.editor.ui.Editor();
	            editorcontent.render( 'content' );
	            try{editorcontent.sync();}catch(err){};
	            //增加编辑器验证规则
	            jQuery.validator.addMethod('editorcontent',function(){
	                try{editorcontent.sync();}catch(err){};
	                return editorcontent.hasContents();
	            });
	            var form = $('form.js-ajax-forms');
	        //ie处理placeholder提交问题
	        if ($.browser.msie) {
	            form.find('[placeholder]').each(function () {
	                var input = $(this);
	                if (input.val() == input.attr('placeholder')) {
	                    input.val('');
	                }
	            });
	        }
	        //表单验证开始
	        form.validate({
				//是否在获取焦点时验证
				onfocusout:false,
				//是否在敲击键盘时验证
				onkeyup:false,
				//当鼠标掉级时验证
				onclick: false,
	            //验证错误
	            showErrors: function (errorMap, errorArr) {
					//errorMap {'name':'错误信息'}
					//errorArr [{'message':'错误信息',element:({})}]
					try{
						$(errorArr[0].element).focus();
						art.dialog({
							id:'error',
							icon: 'error',
							lock: true,
							fixed: true,
							background:"#CCCCCC",
							opacity:0,
							content: errorArr[0].message,
							cancelVal: '确定',
							cancel: function(){
								$(errorArr[0].element).focus();
							}
						});
					}catch(err){
					}
	            },
	            //验证规则
	            rules: {'cs_name':{required:1},'cs_price':{required:1},'cs_teacher':{required:1},'sec_numbers':{required:1},'cs_brief':{required:1}},
	            //验证未通过提示消息
	            messages: {'cs_name':{required:'课程名称不能为空'},'cs_price':{required:'课程价格不能为空'},'cs_teacher':{required:'主讲老师不能为空'},'sec_numbers':{required:'章节数量不能为空'},'cs_brief':{required:'课程描述不能为空'}},
	            //给未通过验证的元素加效果,闪烁等
	            highlight: false,
	            //是否在获取焦点时验证
	            onfocusout: false,
	            //验证通过，提交表单
	            submitHandler: function (forms) {
	                $(forms).ajaxSubmit({
	                    url: form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
	                    dataType: 'json',
	                    beforeSubmit: function (arr, $form, options) {
	                        
	                    },
	                    success: function (data, statusText, xhr, $form) {
	                        if(data.status){
								setCookie("refersh_time",1);
								//添加成功
								Wind.use("artDialog", function () {
								    art.dialog({
								        id: "succeed",
								        icon: "succeed",
								        fixed: true,
								        lock: true,
								        background: "#CCCCCC",
								        opacity: 0,
								        content: data.info,
										button:[
											{
												name: '继续添加？',
												callback:function(){
													location='{:U('Center/createcourse')}';
													return true;
												},
												focus: true
											},{
												name: '返回列表页',
												callback:function(){
													location='{:U('Center/index')}';
													return true;
												}
											}
										]
								    });
								});
							}else{
								isalert(data.info);
							}
	                    }
	                });
	            }
	        });
	    });
	////-------------------------
});
</script>
<tc_include file="Public:footer" />